<template>
  <div class="app-container">
    <!-- 路由出口，显示当前路由对应的组件 -->
    <router-view />
  </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { store } from './store/index.js'

const router = useRouter()

// 初始化时检查登录状态
onMounted(() => {
  // 检查本地存储的token
  const token = localStorage.getItem('token')
  const userInfo = localStorage.getItem('userInfo')
  
  if (token && userInfo) {
    // 恢复用户登录状态
    store.commit('setToken', token)
    store.commit('setUserInfo', JSON.parse(userInfo))
  }
})
</script>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f5f7fa;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  width: 100%;
}

/* 确保路由组件占据整个容器 */
.router-view {
  width: 100%;
  min-height: 100vh;
}
</style>